package sgbag1.Vues;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

import java.awt.Point;

import java.awt.Rectangle;

import java.awt.RenderingHints;
import java.awt.geom.Point2D;

import sgbag1.Noyau.Chariot;
import sgbag1.Noyau.Global;

public class VueChariot_init extends Vue_init {
    
    private int rayon = 10;
    private Chariot chariot;
    private Color couleurLibre = new Color(0, 139, 0);
    private Color couleurOccupe = new Color(220, 20, 60);
    private Point2D position;
    
    public VueChariot_init(Chariot c) {
        super();
        
        chariot = c;
        position = c.getPosition();
    }

    @Override
    public void Dessiner(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        
        g2.setColor(couleurLibre);

        if(chariot.getEtat() == Global.LIBRE){
            g2.setColor(couleurLibre);
        }
        else{
            g2.setColor(couleurOccupe);
        }
       
        position = chariot.getPosition();
        
        this.CalculerBoiteEnglobante();
        
        g2.fillOval((int)position.getX() - rayon, (int)position.getY() - rayon, 2 * rayon, 2 * rayon);
               
        super.Dessiner(g);
    }

    @Override
    public void CalculerBoiteEnglobante() {
        boiteEnglobante = new Rectangle((int)position.getX() - rayon, (int)position.getY() - rayon, 2 * rayon, 2 * rayon);
    }
}
